import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		Token: localStorage.getItem("token"),
		all_envelope: {},
		user_envelope_id: null,
		params: JSON.parse(localStorage.getItem('params')),
		order: JSON.parse(localStorage.getItem('order')),
		url: localStorage.getItem('url'),
		apps:{}//下载app 链接
	},
	mutations: {
		change_all_envelope (state, data) {
			state.all_envelope = data
		},
		change_user_envelope_id (state, id) {
			state.user_envelope_id = id
		},

		set_app_infos(state,data){
			state.apps=Object.assign({},data)
			localStorage.setItem('store',JSON.stringify(state))
		}
	},
	actions: {
		async_change_all_envelope ({ commit }, all_envelope) {
			commit('change_all_envelope', all_envelope)
		},
		async_change_user_envelope_id ({ commit }, id) {
			commit('change_user_envelope_id', id)
		}
	},
	modules: {},
});
